package fm.sys.token;

import java.sql.Timestamp;


/**
 * 用于CS交互过程中的验证数据，有时间限制，携带手机号码、其他数据（如微信的openid）
 */
public class Token {
    protected Timestamp timestamp;
    protected String key;
    protected String otherData;

    public Token(Timestamp timestamp, String key, String otherData) {
        this.timestamp = timestamp;
        this.key = key;
        this.otherData = otherData;
    }

    public Timestamp getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Timestamp timestamp) {
        this.timestamp = timestamp;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getOtherData() {
        return otherData;
    }

    public void setOtherData(String otherData) {
        this.otherData = otherData;
    }


    public boolean isExpired() {
        Timestamp now = new Timestamp(System.currentTimeMillis());
        long expiredTime = 15 * 24 * 60 * 60 * 1000;
        if ((now.getTime() - this.timestamp.getTime()) > expiredTime) {
            return true;
        }
        return false;
    }
}
